package com.xfsg.core.log.config;

import com.xfsg.core.log.logger.PitayaLogger;
import com.xfsg.core.rocketmq.RocketMqRunner;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ZhangYi
 * @classname RocketmqLogTraceAutoConfiguration
 * @description TODO
 * @date 2022/2/19 14:24
 */
@Configuration
@AutoConfigureAfter(PitayaLogger.class)
@ConditionalOnClass(name = {"org.apache.rocketmq.spring.support.DefaultRocketMQListenerContainer","org.apache.rocketmq.spring.core.RocketMQTemplate"})
public class RocketmqLogTraceAutoConfiguration {

    @Bean
    @ConditionalOnBean(value = PitayaLogger.class)
    public RocketMqRunner rocketMqRunner(PitayaLogger pitayaLogger) {
        return new RocketMqRunner(pitayaLogger.getServiceId());
    }

}
